package com.guchenbo.submit;

import org.apache.spark.deploy.SparkSubmit;
import org.junit.Test;

public class ParseOptions {

  @Test
  public void optJars() {
    // --jars
    // set HADOOP_CONF_DIR
    String[] submitArgs = {"--class", "org.apache.spark.examples.SparkPi", "--master", "yarn",
        "--deploy-mode", "cluster", "-v", "--jars",
        "/Users/guchenbo/opt/install/spark-2.4.7-bin-hadoop2.7/jars/commons-math3-3.4.1.jar",
        "--conf",
        "spark.yarn.dist.jars=/Users/guchenbo/opt/install/spark-2.4.7-bin-hadoop2.7/jars/commons-lang3-3.5.jar",
        "/Users/guchenbo/opt/install/spark-2.4.7-bin-hadoop2.7/examples/jars/spark-examples_2.11-2.4.7.jar",
        "this is arg"};
    SparkSubmit.main(submitArgs);
  }

  @Test
  public void optPyFiles() {
    // --py-files
    // set HADOOP_CONF_DIR
    String[] submitArgs = {"--master", "yarn",
        "--deploy-mode", "cluster", "-v",
        "--py-files",
        "/Users/guchenbo/opt/install/spark-2.4.7-bin-hadoop2.7/examples/src/main/python/als.py",
        "/Users/guchenbo/opt/install/spark-2.4.7-bin-hadoop2.7/examples/src/main/python/pi.py",
        "this is arg"};
    SparkSubmit.main(submitArgs);
  }
}
